package tools;

import controller.MusicController;
import controller.UserController;
import impl.service.UploadSql;
import model.ResponseBodyMessage;

import java.util.Map;

public class Feature {
    public Object result(String type, Map<String,String> data){
        System.out.println("type---->" + type);
        switch (type){
            case "login"://用户登录
                System.out.println("登录");
                return new UserController().login(data.get("username"),data.get("password"));
            case "sign"://用户注册
                return new UserController().sign(data.get( "username"),data.get("password"));
            case "allmusic"://全部歌曲
                return new MusicController().getMusic();
            case "lovemusic"://我喜欢
                return new MusicController().getLoveMusic(Integer.valueOf(data.get("id")));
            case "latelyusic"://最近播放
                return new MusicController().getLatelyMusic(Integer.valueOf(data.get("id")));
            case "listmusic"://歌单音乐
                return new MusicController().getListMusic(Integer.valueOf(data.get("id")));
            case "list"://音乐歌单
                return new MusicController().getlist(Integer.valueOf(data.get("id")));
            case "deletemusic"://删除音乐
                return new MusicController().deleteMusic(Integer.valueOf(data.get("id")),data.get("musicId"));
            case "deletemusicforlove"://删除音乐从我的喜欢
                return new MusicController().deleteMusicForLove(Integer.valueOf(data.get("id")),data.get("musicId"));
            case "deletelist"://删除歌单
                System.out.println("删除歌单");
                return new MusicController().deleteList(Integer.valueOf(data.get("id")));
            case "search"://搜索音乐
                return new MusicController().getSearchMusic(data.get("search"));
            case "update"://更新音乐
                return new MusicController().update(Integer.valueOf(data.get("id")),data.get("url"));
            case "userid":
                UploadSql.userId =  Integer.valueOf (data.get("id"));
                return new ResponseBodyMessage<Boolean>(true,"已连接服务器，开始上传文件",true);
            case "createlist"://创建音乐歌单
                return new MusicController().createList(Integer.valueOf(data.get("id")),data.get("name"));
            case  "insertToLove":
                return new MusicController().insertToLove(data.get("url"),Integer.valueOf(data.get("id")));
            case "insertToList":
                return new MusicController().insertToList(data.get("url"),Integer.valueOf(data.get("id")));
            default:
                return "没有该功能";
        }
    }
}
